/**
 * 推荐页的一些函数
 */
import jsonp from 'common/js/jsonp'
import {commonParams, options} from './config'
import axios from 'axios'

export function getRecommend () {
  const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'
  const data = Object.assign({}, commonParams, {
    platform: 'h5',
    uin: 0,
    needNewCode: 1,
    _: Date.now()
  })
  return jsonp(url, data, options)
}

export async function getDiscList () {
  const url = 'api/getDiscList'
  const data = Object.assign({}, commonParams, {
    picmid: 1,
    g_tk: 5381,
    rnd: Math.random(),
    loginUin: 0,
    hostUin: 0,
    notice: 0,
    platform: 'yqq.json',
    needNewCode: 0,
    categoryId: 10000000,
    sortId: 5,
    sin: 0,
    ein: 19
  })
  let result = null
  try {
    result = await axios.get(url, {
      params: data
    })
  } catch (e) {
    console.log(e.message)
  }
  return result
}
